import axios from '@/libs/api.request'
import { getToken } from '@/libs/util'
import platform from '@/config/platform'

// 新增部门
export const addDept = (data) => {
  return axios.request({
    url: platform.AUTH + '/dept',
    method: 'post',
    data
  })
}
// 编辑部门
export const editDept = (data) => {
  return axios.request({
    url: platform.AUTH + '/dept',
    method: 'put',
    data
  })
}
// 回显部门
export const lookDetailsDept = (id) => {
  return axios.request({
    url: platform.AUTH + `/dept/${id}`,
    method: 'get'
  })
}
// 删除部门
export const delDept = (id) => {
  return axios.request({
    url: platform.AUTH + `/dept/${id}`,
    method: 'delete'
  })
}
// 查询主体用户列表
export const getMainUserList = (data) => {
  return axios.request({
    url: platform.AUTH + '/dept/main-user-list',
    method: 'get',
    params: { ...data }
  })
}
// 查询子用户列表
export const getSubUserList = (data) => {
  return axios.request({
    url: platform.AUTH + '/dept/sub-user-list',
    method: 'get',
    params: { ...data }
  })
}
// 查询编辑上级部门
export const getDeptList = (data) => {
  return axios.request({
    url: platform.AUTH + '/dept/parent-list',
    method: 'get',
    params: { ...data }
  })
}

// 查询新增上级部门
export const getDeptsList = (data) => {
  return axios.request({
    url: platform.AUTH + '/dept/list',
    method: 'get',
    params: { ...data }
  })
}
